<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ include file="/wesite/view/common/base.jsp" %>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>采购提醒</title>
    <%@ include file="/wesite/view/common/common.jsp" %>
</head>
<body>
<div class="purchase-time">
    <form>
        <div class="box set">
            <div class="con">
                <label>提醒设置</label>
                <input type="checkbox" name="isremind" class="aui-switch" value="1" checked="true">
            </div>
        </div>
        <input type="hidden" name="panid" value="${id}">
        <div class="box remind-cot mt20">
            <div class="box-hd">提醒内容</div>
            <div class="con">
                <textarea name="remindcon" placeholder="请输入提醒内容"></textarea>
                <span class="num"><i>0</i>/75</span>
            </div>
        </div>
        <div class="box mt20 phone">
            <div class="con input">
                <label>手机号码</label>
                <input type="hidden" name="isphone" value="1">
                <input type="text" name="remindphone" placeholder="请输入接收提醒的手机号码">
            </div>
        </div>
        <div class="box remind-time ">
            <div class="con input">
                <label>提醒时间</label>
                <input type="text" name="reminddata" placeholder="选择时间" value="" readonly="">
                <span class="arrow-r"></span>
            </div>
        </div>
        <div class="box repeat-remind" onclick="location.href='E26重复提醒.html'">
            <div class="con input">
                <label>重复提醒</label>
                <input type="text" value="永不" readonly="">
                <span class="arrow-r"></span>
            </div>
        </div>
    </form>
    <div class="purchase-time-btn">
        <span onclick="tosubmit();">完成</span>
    </div>
</div>
</body>
<script type="text/javascript" src="${webctx}/script/aui-calendar.js"></script>
<script type="text/javascript">
    apiready = function () {
        api.parseTapmode();
    }
    $("div.box .con .aui-switch").bind('click', function () {
        if ($(this).is(":checked")) {
            $(this).attr("checked", true);
            $(this).val(1);
        } else {
            $(this).attr("checked", false);
            $(this).val(0);
        }
    });
    var maxCount = 0; // 最高字数，这个值可以自己配置
    $("textarea").on('keyup', function () {
        var len = getStrLength(this.value);
        $(".remind-cot .num i").html(maxCount - len);
    })
    // 中文字符判断
    function getStrLength(str) {
        var len = str.length;
        var reLen = 0;
        for (var i = 0; i < len; i++) {
            if (str.charCodeAt(i) < 27 || str.charCodeAt(i) > 126) {
                // 全角    
                reLen--;
            } else {
                reLen--;
            }
        }
        return reLen;
    }

    var subing = false;
    function tosubmit() {
        if (!$w.isMobile($("[name='remindphone']").val())) {
            new auiToast().fail({
                title: "请输入手机号",
                duration: 2000
            });
            return false;
        }
        if (subing) {
            return false;
        }
        subing = true;
        $w.httpRequest({
            url: apiroot + "/purchasetemp/remindsave",
            data: $("form").serializeArray(),
            ok: function (ret) {
                window.location.href = ctx + "/we/purchaseTemplate/${id}";
            },
            all: function () {
                subing = false;
            }
        })
    }

    var todayDate = new Date();
    var startDate = todayDate.getFullYear() + '-' + (todayDate.getMonth() + 1) + '-' + todayDate.getDate();
    var endDate = (todayDate.getFullYear()) + '-' + (todayDate.getMonth() + 5);
    var calendar = new auiCalendar({
        container: document.getElementById("calendar"), //容器
        startDate: startDate,//开始日期
        endDate: endDate,//结束日期
        lunarShow: true,//是否显示农历
        dateActive: dateActive,//点击日期后回调
        beforeStartDateClick: false//设置今天之前日期是否可点击
    });
    function dateActive(date) {
        $("[name='reminddata']").val(date);
    }
</script>
</html>